#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+10;
int p[MAXN];
vector<pair<long long,long long> > cvq,pld;
int main(){
    freopen("detect.in","r",stdin);

    freopen("detect.out","w",stdout);

    long long T,n,m,l,maxv,d,v,a;
    cin>>T;
    for(int t=1;t<=T;t++){
        cvq.clear();
        pld.clear();
        memset(p,0,sizeof(p));
        cin>>n>>m>>l>>maxv;
        for(int i=1;i<=n;i++){
            cin>>d>>v>>a;
            if(a==0&&v>maxv) cvq.push_back(make_pair(d,l));
            else if(a>0&&v>maxv) cvq.push_back(make_pair(d,l));
            else if(a>0&&v==maxv) cvq.push_back(make_pair(d+1,l));
            else if(a>0&&v*v+2*a*(l-d)>maxv*maxv) cvq.push_back(make_pair((maxv*maxv-v*v)/(2*a)+d+((maxv*maxv-v*v)%(2*a)==0?1:0),l));
            else if(a<0&&v>maxv) cvq.push_back(make_pair(d,(maxv*maxv-v*v-1)/(2*a)+d));
            /*
            if(!cvq.empty()){
                auto dbg=cvq[cvq.size()-1];
                cout<<d<<" "<<v<<" "<<a<<endl;
                cout<<dbg.first<<" "<<dbg.second<<endl<<endl;
            }
            */


        }
        for(int i=1;i<=m;i++)
            cin>>p[i];
        int lp=p[1],rp=p[m];
        for(auto i:cvq){
            if(i.first>rp||i.second<lp) continue;
            int ft=lower_bound(p+1,p+1+m,i.first)-p;
            int st=(upper_bound(p+1,p+1+m,i.second)-p)-1;
            if(st<=0||ft<=0||st>=m+1||ft>=m+1) continue;
            if(p[ft]>=i.first&&p[st]<=i.second&&ft<=st) pld.push_back(make_pair(ft,st));
        }
        sort(pld.begin(),pld.end());

        cout<<pld.size()<<" ";

        stack<pair<long long,long long> > stk;
        for(auto i:pld){
            //cout<<i.first<<" "<<i.second<<endl;
            while(!stk.empty()&&i.first>=stk.top().first&&i.second<=stk.top().second)
                stk.pop();
            stk.push(i);
        }
        pld.clear();
        long long ans=0;
        long long pos=m+1;
        while(!stk.empty()){
            //cout<<stk.top().first<<" "<<stk.top().second<<endl;
            if(stk.top().second<pos){
                ans++;
                pos=stk.top().first;
            }
            stk.pop();
        }
        cout<<m-ans<<endl;
    }

    return 0;
}


